// Copyright (c) 2008 Matthew Johnson
// Licensed under the MIT License (see license.txt)
package actionml.geom {
	import actionml.Global;
	
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class PointMethods {
		public static function initialize() {
			Global.initializeExtension(PointMethods, Point);
		}
		public static var instanceMethods:Object = {
			getDistanceFrom: function(x:Number, y:Number) {
				return Point.distance(this, new Point(x, y));
			},
			getDistanceFromPoint: function(p:Point) {
				return Point.distance(this, p);
			},
			
			getRadiansFrom: function(x:Number, y:Number) {
				return Object(Math.atan2(y - this.y, x - this.x)).normalizeRadiansToCycle();
			},
			getRadiansFromPoint: function(p:Point) {
				return Object(Math.atan2(p.y - this.y, p.x - this.x)).normalizeRadiansToCycle();
			},
			getDegreesFrom: function(x:Number, y:Number) {
				return this.getRadiansFrom(x, y).toDegrees();
			},
			getDegreesFromPoint: function(p:Point) {
				return this.getRadiansFromPoint(p).toDegrees();
			},
			
			addRadians: function(distance:Number, radians:Number) {
				return this.add(Point.polar(distance, radians));
			},
			addDegrees: function(distance:Number, degrees:Number) {
				return this.addRadians(distance, degrees.toRadians());
			}
		};
	}
}